<?php

use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Admin::css('/vendor/mango/main.css');

Grid::resolving(function (Grid $grid) {
    if (env('IS_DEMO') == true) {
        $grid->disableActions();
        $grid->disableCreateButton();
        $grid->disableEditButton();
    }
    $grid->setActionClass(\Dcat\Admin\Grid\Displayers\Actions::class); // 列中操作直接显示 不要默认的三个点
    $grid->showColumnSelector(); // 开启右边的字段显示选择
    // $grid->model()->orderBy("id", "desc");
    $grid->disableViewButton(); // 禁用详情按钮
    $grid->showQuickEditButton();  // 开启快速编辑 
    $grid->enableDialogCreate(); // 启用弹窗创建

    $grid->actions(function (\Dcat\Admin\Grid\Displayers\Actions $actions) {
        $actions->disableView();
        $actions->disableEdit();
    });
    $grid->option("dialog_form_area", ["65%", "85%"]);
});

Form::resolving(function (Form $form) {
    if (env('IS_DEMO') == true) {
        $form->disableCreatingCheck();
        $form->disableEditingCheck();
        $form->disableViewCheck();
        $form->disableSubmitButton();
    }
});

Filter::resolving(function (Filter $filter) {
    $filter->panel(); // 不以默认的侧边显示搜索   直接当前页显示
    // $filter->expand();// 是否显示搜索条件 默认不显示 点击筛选后才出现 设置后就直接显示
});


